package com.topc.participant.api;

import com.topc.participant.service.ICourseInfoService;
import com.topc.participant.service.ICourseUserMidService;
import com.topc.participant.service.IUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

@RestController
@RequestMapping("/open/course")
public class CourseOpenController {

    @Autowired
    private ICourseInfoService courseInfoService;

    @Autowired
    private IUserInfoService userInfoService;

    @Autowired
    private ICourseUserMidService courseUserMidService;


    //获取用户所有课程ID
    @PostMapping("/get-user-course-id")
    public List<Long> getUserCourseId(@NotNull String userNumber){
        System.out.println("======================>userNumber:"+userNumber);
        List<Long>courseIds = courseUserMidService.getCourseListByNumber(userNumber);
        return courseIds;
    }

    //查询课程中是否存在该用户
    @PostMapping("/search-user-count")
    public int searchUserCount(@NotNull Long courseId, @NotNull String userNumber){
        return courseUserMidService.searchUserCount(courseId,userNumber);
    }
}
